package com.alfredo.android.appcaja.util;

import java.util.ArrayList;

import com.alfredo.android.appcaja.model.Orden;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.Html;

public class Utils 
{
	public static void enviarEmail(Context context, String cabeceraSubject, Orden orden,String body, String[] urlsFotos)
	{
		Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
		
		String subject = "";
		
		if(orden != null)
			subject = cabeceraSubject+" - CGI: "+orden.getCgi()+" Numero de expediente: "+orden.getNroExpediente()+" Causante/Beneficiario: "+orden.getCausanteBeneficiario();
		
		emailIntent.setType("text/plain");
		emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{"informespreliminarescaja@gmail.com"});
		emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); 
		emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
		
		if(urlsFotos != null)
		{
			ArrayList<Uri> uris = new ArrayList<Uri>();
			for(int i=0; i<urlsFotos.length; i++)
            {
				uris.add(Uri.parse("file://" + urlsFotos[i]));
            }
			emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
		}
		
		context.startActivity(Intent.createChooser(emailIntent, "Email:"));
	}
}
